import {baseUrl} from "../constants/url";
import {myReq} from "./utils";

const audioUrl = baseUrl + '/audio'

// 获取所有音乐
export function getMusics(onSuccess) {
    myReq(audioUrl, null, 'GET', onSuccess)
}

// 用户创建歌单
export function createList(userId, title, onSuccess) {
    myReq(`${audioUrl}/list`, {userId, title}, 'POST', onSuccess)
}

// 添加歌曲到歌单
export function addMusicToListApi(musicId, listId, onSuccess) {
    myReq(`${audioUrl}/list`, {musicId, listId}, 'PUT', onSuccess)
}

// 根据歌单id获取歌单detail
export function getListDetail(lid,onSuccess){
    myReq(`${audioUrl}/list/detail`,{lid},'GET', onSuccess)
}